<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
 '
 ' Copyright 2007 Liu, Xiaokang <4341322@gmail.com>
 ' Blog <http://www.ioio.name/>
 ' 
 ' This file is part of JOS(Judge Online System).
 ' You can see this project at <http://code.google.com/p/judgeonline/>
 ' 
 ' JOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 ' published by the Free Software Foundation; either revision 3 of the License, or (at your option) any later revision.
 ' 
 ' JOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 ' 
 ' You should have received a copy of the GNU General Public License along with JOS. if not, see
 ' <http://www.gnu.org/licenses/>.
 '
%>
<%Option Explicit%>
<%
	Dim PageTitle
  PageTitle="Record"
%>
<!--#include file="Header.asp"-->
<div id="Main">
  <div class="CodeViewx" align="center">
  <div style="width:80%; background-color:#F4FBFF;">
     <% 
   Dim RecordId
   If Not isempty(Request("Rid")) Then
      RecordId=Clng(Request("Rid"))
   
   Dim Sr
   conn.Open connstr
   Set Sr = Server.CreateObject("ADODB.Recordset")
   Sr.Open "Select * From [Records] Where Records.Rid="+ Request("Rid") ,conn,1,3 
   If  Sr.eof Or Sr.Bof then
   Response.Write "Permission Denied."
   Else
   If Session("Uid")=Sr("Uid") OR (Request.Cookies(CookiesName)("Permission")<3 and Request.Cookies(CookiesName)("Permission")) Then
	%>
    <script type=text/javascript src="Scripts/utility.js"></script>
<%If Sr("Compiler")="GCC" OR Sr("Compiler")="CPP" Then %>
<script type=text/javascript src="Scripts/cpp_coderender.js"></script>
<%End If%>
<%If Sr("Compiler")="JAVA" Then %>
<script type=text/javascript src="Scripts/java_coderender.js"></script>
<%End If%>

<div align=center style="font-family:Arial;border-bottom:#B7CBFF 1px dashed;padding:6px"><b><font color=green>Problem : <a href='Problem_View.asp?Pid=<%=Sr("Pid")%>' target=_blank><%=Sr("Pid")%></a> &nbsp;&nbsp;&nbsp;&nbsp;Judge Status : <%
		Select Case Sr("Status")
		Case -1:Response.Write "Queuing"
		Case 0:	Response.Write "<font color=""red"">Accepted</font>"
		Case 1: Response.Write "Compiling"
   		Case 2: Response.Write "Compilation Error"
   		Case 3: Response.Write "Running"
   		Case 4: Response.Write "Runtime Error"
   		Case 5: Response.Write "Presentation Error"
   		Case 6: Response.Write "Wrong Answer"
   		Case 7: Response.Write "Output Limit Exceeded"
   		Case 8: Response.Write "Time Limit Exceeded"
		Case 9: Response.Write "Memory Limit Exceeded"
		Case 10: Response.Write "Restricted Function"
		Case 11: Response.Write "Validate Error"
		Case 12: Response.Write "Out Of Contest Time"
		Case 13: Response.Write "No Such Problem"
		Case 14: Response.Write "System Erorr"
		End Select%><br>RunId : <%=Sr("Rid")%>&nbsp;&nbsp;&nbsp;&nbsp;Language : <%=Sr("Compiler")%>&nbsp;&nbsp;&nbsp;&nbsp;Author : <a href="User_Status.asp?Uid=<%=Sr("Uid")%>" target=_blank>
		<%
		Dim  UsernameRS
		Set UsernameRS = Server.CreateObject("ADODB.Recordset")
   UsernameRS.Open "Select Username From [Members] Where Uid="+ CStr(Sr("Uid")) ,conn,1,3 
   If Not UsernameRS.eof and Not UsernameRS.Bof then
   Response.Write UsernameRS("Username")
   End If
   UsernameRS.Close
	Set UsernameRS=nothing
		%></a><!--<br>Code Render Status : <font color=#FF00FF>Rendered By HDOJ G++ Code Rander Version 0.01 Beta</font>--></b></div>

<textarea id=usercode style="display:none;text-align:left;"><%=Sr("Code")%></textarea>
<div style="padding:10px"><pre style="font-family:Courier New;text-align:left;">
<%If Sr("Compiler")="GCC" OR Sr("Compiler")="CPP" OR Sr("Compiler")="JAVA" Then %>
<script language=javascript>document.write(renderCode(document.getElementById('usercode').value));</script>
<%ELSE%>
<script language=javascript>document.write(toHTML(document.getElementById('usercode').value));</script>
<%End If%>
</pre></div>
<%
Dim savename
Select Case Sr("Compiler")
		Case "FPC":savename="HOJ"+CStr(Sr("Pid"))+".pas"
		Case "TPC":savename="HOJ"+CStr(Sr("Pid"))+".pas"
		Case "GCC":savename="HOJ"+CStr(Sr("Pid"))+".c"
		Case "CPP":savename="HOJ"+CStr(Sr("Pid"))+".cpp"
		Case "JAVA":savename="HOJ"+CStr(Sr("Pid"))+".java"
End Select%>

<div style="font-size:12px;font-weight:bold" align=center><a href="javascript:" onclick="copyCode(document.getElementById('usercode'));">[ Copy to Clipboard ]</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:" onclick="saveCode(document.getElementById('usercode'), '<%=savename%>');">[ Save to File]</a><br><br></div>

  <%Else
	Response.Write "Permission Denied."
	End If
	End If
	Sr.Close
	Set Sr=nothing
    End If
	conn.Close
   %>   
  </div>
  </div>
</div>
<!--#include file="Footer.asp"-->